<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>0</h1>
<script>
    let i = document.querySelector("h1");
    let count = 0
    //设置间隔（0.1s）
    let t = setInterval(f,100);
    function f(){
        count++

        if (count>=50){
            //停止定时器
            clearInterval(time);
        }
        i.innerText = count;
    }

    //只执行一次的定时器
    setTimeout(h,3000)
    function h(){
        alert("fuck you bitch!")
    }


</script>


</body>
</html>